a = input()
x = len(a)
d = 0
count = a.count('(')
count1 = a.count(')')
count2 = a.count('[')
count3 = a.count(']')
count4 = a.count('{')
count5 = a.count('}')
for i in range(len(a)):
    for x in range(len(a)):
        if (a[i] == '(' and a[x] == ')') or (a[i] == '[' and a[x] == ']') or (a[i] == '{' and a[x] == '}'):
            d += 1
if (d == len(a) / 2 and len(a)%2 == 0)or (count == count1 and count2 == count3 and  count4 == count5):
    print('Последовательность верная')
else:
    print('Последовательность неверная')
